package examples;

import impsoft.bots.ColorBot;
import impsoft.bots.reflection.NPC;
import impsoft.bots.reflection.Player;
import looting.LootItem;
import looting.LootTable;
import base.DreamScript;

public class ChickenKiller extends DreamScript {

	public int chickenId = 0;
	public int healAt = 0;
	public boolean lootFeathers;
	public LootTable lootTable;

	public ChickenKiller(ColorBot d) {
		super(d);
	}

	@Override
	public void script() throws InterruptedException, Exception {
		rebrand();

		log("Welcome to " + name + " brought to you by " + author + " from " + website);
		log("Downloading the loot table...");
		lootTable.loadMasterTable("www.autofighter.ak4322.info/itemData.csv");

		while (true) {
			NPC chicken = getMyPlayer().getInteractingNPC();// getNPC;

			if (chicken != null && !getCombatUtils().isPlayerFightingNPC(chicken)) {
				// click it
				// sleep until not moving

				Player player = null;
				while ((player = getCombatUtils().getPlayerFightingNPC(chicken)) != null
						&& player.equals(getMyPlayer())) {
					if (theMiniMapIndicators.getHealthPoints() < healAt) {
						while (theMiniMapIndicators.getHealthPoints() < healAt) {
							getFoodManager().heal();
							sleep(1000);
						}
					}

					sleep(1000);
				}

				if (chicken == null || chicken.getHPRatio() < 1) {
					LootItem item = lootTable.get("Feather");
				}
			}
		}
	}
}
